﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CongregacaoOs.WebForm
{
    static class Functions
    {
        public static void LimparCampos(Control controle)
        {
            foreach (Control ctrl in controle.Controls)
            {
                if (ctrl is TextBox) ((TextBox)ctrl).Text = string.Empty;
                else if (ctrl.Controls.Count > 0)
                {
                    LimparCampos(ctrl);
                }

                if (ctrl is DropDownList)
                {
                    if (((DropDownList)ctrl).Items.Count > 0)
                    { 
                        ((DropDownList)ctrl).SelectedIndex = 0; 
                    }
                }
                else if (ctrl.Controls.Count > 0)
                {
                    LimparCampos(ctrl);
                }
            }
        }
    }
}